<?php

	$url = $_REQUEST['url'];

	$expected=array(
			'request'
		,	'service'
		,	'version'
		,	'outputformat'
		,	'TypeName'

		,	'srs'
		,	'format'
		,	'bbox'
		,	'width'
		,	'height'
		,	'styles'
		,	'query_layers'
		,	'x'
		,	'y'
		,	'info_format'
		,	'feature_count'
		,	'exceptions'
		,	'servicename'
		,	'layers'
		,	'FILTER'
		,	'REQUEST'
		,	'TYPENAME'
		,	'CQL_FILTER'
	);
	
	// Initialize allowed variables
	foreach ($expected as $formvar)
		$$formvar = (isset(${"_$_SERVER[REQUEST_METHOD]"}[$formvar])) ? ${"_$_SERVER[REQUEST_METHOD]"}[$formvar]:NULL;	

	$extra = "?";
	foreach($expected as $name){
		if ($$name != '') {
			$extra .= $name . "=" . ($$name) . "&";
		}
	}
	
// print $url . $extra;
#exit();
	header ("content-type: text/xml");
	print file_get_contents($url . $extra); 
/*
	$opts = array(
		'http'=>array(
			'method'=>"GET",
			'header'=>"Accept-language: en\r\n" .
								"Cookie: foo=bar\r\n"
		)
	);
	
	$context = stream_context_create($opts);
*/
//	print file_get_contents("http://birdlaa2.memset.net:8080/geoserver/wfs?FILTER=<Filter><PropertyIsEqualTo><PropertyName>spcrecid</PropertyName><Literal>64</Literal></PropertyIsEqualTo></Filter>&REQUEST=GetFeature&TYPENAME=birdlife:gtbs&", false );
?>